import os
from shutil import copyfile

video_path = r'D:\pycharmProj\my-yolov5\runs\detect\exp3\videos'
target_dir = r"E:\uav_datasets\Drone_detection_dataset-UAV2-3dCNN"  # + 'AIRPLANE', 'BIRD', 'DRONE', 'HELICOPTER'

for sub_path in os.listdir(video_path):
    print(sub_path)
    src_dir = os.path.join(video_path, sub_path)
    cls = sub_path.split("_")[1]
    mv_tg_dir = os.path.join(target_dir, "UAV")
    if cls == "BIRD":  # 鸟类目标单独分类,其他三类无人机目标统一分类到UAV目录下
        mv_tg_dir = os.path.join(target_dir, "BIRD")
    if not os.path.exists(mv_tg_dir): os.mkdir(mv_tg_dir)

    # 复制文件到mv_tg_dir
    for file_name in os.listdir(src_dir):
        copyfile(os.path.join(src_dir, file_name),
                 os.path.join(mv_tg_dir, file_name))
